﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TangCaptureTraffic.Forms
{
    public partial class Setting : UserControl
    {
        public bool EnableAutoMemoryCleanup;
        public int MemoryCleanupInterval;
        public int MaxSessions;
        public int SessionCleanupCount;
        public int MaxUISessions;
        public int UISessionCleanupCount;
        public int MemoryWarningThreshold;
        public Setting()
        {
            InitializeComponent();
            switch1.Checked = EnableAutoMemoryCleanup = MemoryConfig.EnableAutoMemoryCleanup;
            inputNumber1.Value = MemoryCleanupInterval = MemoryConfig.MemoryCleanupInterval;
            inputNumber2.Value = MaxSessions = MemoryConfig.MaxSessions;
            inputNumber3.Value = SessionCleanupCount = MemoryConfig.SessionCleanupCount;
            inputNumber4.Value = MaxUISessions = MemoryConfig.MaxUISessions;
            inputNumber5.Value = UISessionCleanupCount = MemoryConfig.UISessionCleanupCount;
            inputNumber6.Value = MemoryWarningThreshold = MemoryConfig.MemoryWarningThreshold;

            switch1.CheckedChanged += (s, e) =>
            {
                EnableAutoMemoryCleanup = e.Value;
            };
            inputNumber1.ValueChanged += (s, e) =>
            {
                MemoryCleanupInterval = (int)e.Value;
            };
            inputNumber2.ValueChanged += (s, e) =>
            {
                MaxSessions = (int)e.Value;
            };
            inputNumber3.ValueChanged += (s, e) =>
            {
                SessionCleanupCount = (int)e.Value;
            };
            inputNumber4.ValueChanged += (s, e) =>
            {
                MaxUISessions = (int)e.Value;
            };
            inputNumber5.ValueChanged += (s, e) =>
            {
                UISessionCleanupCount = (int)e.Value;
            };
            inputNumber6.ValueChanged += (s, e) =>
            {
                MemoryWarningThreshold = (int)e.Value;
            };

        }

    }
}
